package com.example.demo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerTitleStrip;
import android.support.v4.view.ViewPager;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;

public class FragmentViewPage extends SherlockFragmentActivity  {

	ViewPager viewPager ;
	PagerTitleStrip pagerTitleStrip;
	SectionsPagerAdapter mSectionsPagerAdapter;

	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_viewpager);
		
		mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

		
		viewPager = (ViewPager) findViewById(R.id.pager);
//		pagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
		viewPager.setAdapter(mSectionsPagerAdapter);
		
		
		
		
	}
	
	
	
	public class SectionsPagerAdapter extends FragmentPagerAdapter {
		 
		        public SectionsPagerAdapter(FragmentManager fm) {
		            super(fm);
		        }
		 
		        @Override
		        public Fragment getItem(int position) {
		            // getItem is called to instantiate the fragment for the given page.
		            // Return a DummySectionFragment (defined as a static inner class
		            // below) with the page number as its lone argument.
		            Fragment fragment = new PagerOfFragment();
		            Bundle args = new Bundle();
		            args.putInt("no", position + 1);
		            fragment.setArguments(args);
		 
		            return fragment;
		        }
		 
		        @Override
		        public int getCount() {
		            // Show 3 total pages.
		            return 3;
		        }
		 
		        @Override
		        public CharSequence getPageTitle(int position) {
		            switch (position) {
		            case 0:
		                return "标签1";
		            case 1:
		                return "标签2";
		            case 2:
		                return "标签3";
		            }
		            return null;
		        }
		    }

	
	
}
